import { asClass, asFunction, createContainer, InjectionMode } from "awilix";
import { IndexController } from "./controllers/indexController";
import { ProxyController } from "./controllers/proxyController";
import { FilmReleaseController } from "./controllers/shotstack/filmReleaseController";
import { SystemController } from "./controllers/systemController";
import { UserController } from "./controllers/userController";
import { FilmReleaseService } from "./services/filmReleaseService";
import { RequestFactory } from "./libs/request";
import { FilmMultimediaRelationJob } from "./jobs/filmMultimediaRelationJob";
import { PlatformDouyinPublishJob } from "./jobs/platformDouyinPublishJob";
import { PlatformUserAccountService } from "./services/platformUserAccountService";
import { PlatformFactory } from "./libs/platform/platformFactory";
import { Uploader, UploaderFactory } from "./libs/uploader";

const container = createContainer({
  injectionMode: InjectionMode.PROXY, // 使用代理模式
  strict: true, // 启用严格模式
});

container.register({
  uploader: asClass(Uploader).singleton(),
  uploaderFactory: asFunction(UploaderFactory).singleton(),
  requestFactory: asFunction(RequestFactory).singleton(),
  platformFactory: asFunction(PlatformFactory).singleton(),

  systemController: asClass(SystemController),
  userController: asClass(UserController),
  proxyController: asClass(ProxyController),
  indexController: asClass(IndexController),
  filmReleaseController: asClass(FilmReleaseController),

  filmReleaseService: asClass(FilmReleaseService).singleton(),
  platformUserAccountService: asClass(PlatformUserAccountService).singleton(),

  filmMultimediaRelationJob: asClass(FilmMultimediaRelationJob).singleton(),
  platformDouyinPublishJob: asClass(PlatformDouyinPublishJob).singleton(),
})

export default container;